#include "consignee_main.h"
#include "ui_consignee_main.h"

Consignee_main::Consignee_main(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Consignee_main)
{
    ui->setupUi(this);
    socket = SocketManager::getinstance().socket();
}

Consignee_main::~Consignee_main()
{
    delete ui;
}

void Consignee_main::flush_data()
{
    sendRig meg;
    meg.type=4;
    strcpy(meg.tele,telephone_number.toUtf8());
    QByteArray data;
    data.append((char*)&meg,sizeof (sendRig));
    socket->write(data);
    connect(socket,&QAbstractSocket::readyRead,this,&Consignee_main::f_data);
}

void Consignee_main::f_data()
{
    sendRig * data;
    data = (sendRig*)socket->readAll().data();
    QListWidgetItem * item;
    item->setText(QString("%1  单号:%2  %3")
                  .arg(data->Account)
                  .arg(data->ID)
                  .arg(data->state));
    ui->listWidget->addItem(item);
}
